Pixel access functions have two modes of operation: legacy (prior to ImageGear v14.5) and new (ImageGear v14.5 and newer). The default mode is legacy, in which these functions behave the same way they did before v14.5. So if you have existing code written for ImageGear v14.4 or earlier that uses pixel access functions, you shouldn't need to update it.
New pixel access mode provides more access to the new storage system. It lets you work directly with higher bit depths, advanced color spaces, and alpha/extra channel data included with the main channel data.
If you are migrating from legacy mode to new mode, you must be aware of the following differences between these modes:
- For RGB images, color channel order is RGB (in legacy mode, it is BGR)
- DIBs may use bit depths that were not supported by the Legacy mode (i.e., 36-bit, 48-bit RGB)
- Additional color spaces are supported (i.e., LAB, YUV)
- Alpha and extra channel data is included on a per-pixel basis. For example, if you have a 24-bit RGB image with an 8-bit alpha channel, the pixel data will look like RGBA, RGBA, RGBA and so on, where R, G, B, and A are each one byte.
- Pixel packing and raster padding are as follows:
Packing Mode Legacy New IG_PIXEL_PACKED 1 bit pixels are packed 8 into a byte; 4 bit pixels are packed 2 into a byte; other pixels are not packed. Rasters are padded to DWORD boundary. 1 bit pixels are packed 8 into a byte; other pixels are not packed.
- In 32-bit edition of ImageGear, rasters are padded to DWORD boundary.
- In 64-bit edition of ImageGear, rasters are padded to QWORD boundary.
IG_PIXEL_UNPACKED Pixels are not packed; each 1-bit pixel occupies a byte. Rasters are padded to BYTE boundary. Pixels are not packed; each 1-bit pixel occupies a byte.
- In 32-bit edition of ImageGear, rasters are padded to DWORD boundary;
- In 64-bit edition of ImageGear, rasters are padded to QWORD boundary.
Note that 1-bit pixels are the only pixels that are packed in the new mode - 8 pixels are stored in each byte. Pixels of any other channel depths are stored using 1, 2, or 4 bytes per channel. If a pixel has more than one channel and use 1 bit per channel, each of its channels will be stored in a separate byte. A channel value with depth of 2-8 bits will be stored in one byte, 9-16 bits in two bytes, and 17-32 bits in four bytes.
To use the new mode, you need to set the DIB.PIX_ACCESS_USE_LEGACY_MODE global control parameter to IG_PIX_ACCESS_MODE_NEW, as shown in the example below.
Copy Code | |
---|---|
AT_MODE pixAccessMode = IG_PIX_ACCESS_MODE_NEW; IG_gctrl_item_set("DIB.PIX_ACCESS_USE_LEGACY_MODE", AM_TID_AT_MODE, &pixAccessMode, sizeof(pixAccessMode), NULL); |
If pixel access mode is IG_PIX_ACCESS_MODE_LEGACY, and the image uses a pixel format not supported by the legacy mode, pixel access “…_get” functions convert image pixels into the closest available legacy supported format.